﻿@{
    string action = "";
    if (ViewBag.Action != null) {
        action = (string)ViewBag.Action;
    }
    string formAction = "";
    switch (action) {
        case "C":
            formAction = Url.Action("Create");
            break;
        case "U":
            formAction = Url.Action("Update");
            break;
    }
}
<div title="工种信息">
    <form id="form1" method="post" action="@formAction">
    @Html.ValidationSummary(true)
    </form>
</div>
<div class="form-bar">
    <input id="btnsubmit" type="button" class="button" name="submit" value="提交" />
</div>
@section footer{
    <script src="@Url.Content("~/Scripts/jquery/jquery.validate.min.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/jquery/jquery.metadata.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/jquery/messages_cn.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/jquery.form.js")" type="text/javascript"></script>
    <script type="text/javascript">
        var action = '@action';
        var fields = [
           { display: "工种编号", name: "Id", newline: false, labelWidth: 100, width: 220, space: 30, type: "text", group: "工种信息",
               validate: { required: true, maxlength: 50 }
           }
            , { display: "工种名称", name: "Name", newline: false, labelWidth: 100, width: 220, space: 30, type: "text",
                validate: { required: true, maxlength: 20 }
            }
            , { display: "备注", name: "Remark", newline: true, labelWidth: 100, width: 550, space: 30, type: "textarea",
                validate: { maxlength: 50 }
            }
        ];
        $(function () {
            var form = $("#form1");
            form.ligerForm({ inputWidth: 280, fields: fields });
            if (action != "C") {
                LG.loadForm(form, { url: '@Url.Action("Get")' });
            }
            if (action == 'U' || action == 'C') {
                LG.setFormStatus(form, true, parent);
            } else {
                LG.setFormStatus(form, false);
            }
        });
    </script>
}
